//
//  ILTapWindow.m
//  ILTapGestureRecognizer
//
//  Created by MAC on 14-5-6.
//  Copyright (c) 2014年 example. All rights reserved.
//

#import "ILTapWindow.h"
#import "ILTapGestureRecognizer.h"

@interface ILTapWindow ()
@end

@implementation ILTapWindow

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self doInit];
    }
    return self;
}

- (void)doInit
{
    //创建一个测试的View，我们将手势添加到这个绿色的View上
    UIView *greenView = [[UIView alloc] initWithFrame:self.bounds];
    greenView.backgroundColor = [UIColor greenColor];
    //将greenView添加到当前window上
    [self addSubview:greenView];
    
    ILTapGestureRecognizer *gesture = [[ILTapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
    CGRect bounds= greenView.bounds;
    CGRect tapArea = CGRectMake(0, CGRectGetHeight(bounds) / 2, CGRectGetWidth(bounds), CGRectGetHeight(bounds));
    gesture.responseFrame = tapArea;
    
    [greenView addGestureRecognizer:gesture];
}

- (void)handleTap:(UITapGestureRecognizer *)gesture
{
    //我们获取gesture关联的view,并将view的类名打印出来
    NSString *className = NSStringFromClass([gesture.view class]);
    NSLog(@"您点击了%@", className);
}


@end
